Skip to content

Fix signed-in state handling and improve standalone mode UX - #47

Merged
AlexKempen merged 1 commit into
certfrom
claude/query-states-standalone-button-py80u4
Aug 30, 2026
Merged

Fix signed-in state handling and improve standalone mode UX#47
AlexKempen merged 1 commit into
certfrom
claude/query-states-standalone-button-py80u4

Conversation

@AlexKempen

Copy link
Copy Markdown
Collaborator

Summary

This PR improves how the app handles signed-in state and enhances the standalone (non-Onshape) mode experience. The main changes involve distinguishing between "pending" and "signed out" states, moving sign-in checks into queries, and adding a button to open the app outside of Onshape's panel.

Key Changes

  • Signed-in state handling: useIsSignedIn() now returns boolean | undefined to distinguish between "not yet known" (pending) and "definitely signed out". This prevents UI flashing and incorrect sign-in prompts while access data is loading.

  • Favorites query refactoring: Moved the sign-in check from the component level into getFavoritesQuery() itself using ensureQueryData(). This ensures the query resolves the access state before attempting to fetch, eliminating the need for the enabled flag and preventing the "pending forever" issue.

  • Thumbnail preview loading state: Added explicit handling for the isSignedIn === undefined case to show a loader while access data is being resolved, preventing premature fallback to stored thumbnails.

  • Standalone mode improvements:

    • Added "Open outside Onshape" button in settings (only shown when connected to Onshape)
    • New standaloneUrl() helper generates clean URLs without Onshape launch parameters
    • Updated documentation to clarify the FORCE_SIGNED_IN environment variable and its testing-only purpose
  • Configuration loading: Fixed ConfigurationWrapper to check unitInfoQuery.isLoading in addition to query.isPending, since disabled queries remain pending indefinitely.

  • Insert menu sign-in check: Changed from !isSignedIn to isSignedIn === false to only show the sign-in prompt once the state is definitively known, not while pending.

  • Documentation: Reorganized README to better explain the app architecture and consolidated standalone mode documentation with the FORCE_SIGNED_IN variable explanation.

Implementation Details

The core insight is that React Query's placeholder data and enabled flag can mask the distinction between "loading" and "not signed in". By moving sign-in checks into the query functions themselves and using ensureQueryData() for dependencies, we get clearer state management and better UX when data is still loading.

https://claude.ai/code/session_017qHUwx6dKD8xCnfMwa5JvK

Favorites carried a `placeholderData` of no favorites for the signed-out case,
which also made the pending query look settled and empty: a user with favorites
got the "No favorites" zero state on every open. The query now resolves its own
sign-in dependency, the way useSaveSettings does, so it stays enabled and its
own pending state covers both fetches.

Same bug in two other spots: useIsSignedIn reported the access-data placeholder
as signed out, so the insert menu's preview showed the static thumbnail before
swapping to the live one and toasted a signed-in caller to sign in. It now
reports undefined until the answer lands. The configuration menu waits on the
document's units rather than rendering parameters in the defaults first.

Also add a settings button that opens the app outside the Onshape panel, on the
current library and theme with none of Onshape's launch params.

Trim the README to setup and a high-level description, keeping the local D1/R2
dump import and FORCE_SIGNED_IN with the rest of the setup steps.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017qHUwx6dKD8xCnfMwa5JvK
@AlexKempen
AlexKempen merged commit 6761dd1 into cert Aug 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants